/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.edu.univalle.persistencia;

import co.edu.univalle.modelo.TiposDocumentos;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author DILOVE
 */
@Stateless
public class TiposDocumentoDAO implements ITiposDocumentoDAO {
    @PersistenceContext
    private EntityManager entityManager;
    
    @Override
    public TiposDocumentos consultarPorCodigo(Long codigo) {
        return entityManager.find(TiposDocumentos.class, codigo);
    }

    @Override
    public List<TiposDocumentos> consultar() {
        try{
            String jpql = "select t from TiposDocumentos t";
            Query query = entityManager.createQuery(jpql);
            return query.getResultList();
        }catch(RuntimeException e){
            throw e;
        }
    }
    
}
